#用for...in实现4种九九乘法表

#正向靠左正三角输出九九乘法表
print("NO.1：")
for i in range(1,10):
    for j in range(1,i+1):
        print("{}*{}={:2}".format(i,j,i*j),end=" ")
    print()

#正向正靠右三角输出九九乘法表
print("NO.2：")
for i in range(1,10):
    for k in range(1,10-i):
        print("      ",end = " ")
    for j in range(1,i+1):
        print("{}*{}={:2}".format(i,j,i*j),end=" ")
    print()

#逆向靠左倒三角输出九九乘法表
print("NO.3：")
for i in range(9,0,-1):
    for j in range(i,0,-1):
        print("{}*{}={:2}".format(i,j,i*j),end=" ")
    print()

#逆向靠右倒三角输出九九乘法表
print("NO.4：")
for i in range(9,0,-1):
    for k in range(10-i-1,0,-1):
        print("      ",end = " ")
    for j in range(1,i+1):
        print("{}*{}={:2}".format(i,j,i*j),end=" ")
    print()

#用while实现4种九九乘法表

#正向靠左正三角输出九九乘法表
print("NO.5：")
i = 1
while i<10:
    j=1
    while j<i+1:
        print("{}*{}={:2}".format(i, j, i * j), end=" ")
        j+=1
    print()
    i+=1

#正向靠右正三角输出九九乘法表
print("NO.6：")
i = 1
while i<10:
    k = 1
    while k <10-i:
        print("      ", end=" ")
        k+=1
    j = 1
    while j<i+1:
        print("{}*{}={:2}".format(i, j, i * j), end=" ")
        j+=1
    print()
    i+=1

#逆向靠左倒三角输出九九乘法表
print("NO.7：")
i = 9
while i>0:
    j=i
    while j>0:
        print("{}*{}={:2}".format(i, j, i * j), end=" ")
        j-=1
    print()
    i-=1

#逆向靠右倒三角输出九九乘法表
print("NO.8：")
i = 9
while i>0:
    k = 9-i
    while k > 0:
        print("      ", end=" ")
        k-=1
    j = i
    while j>0:
        print("{}*{}={:2}".format(i, j, i * j), end=" ")
        j-=1
    print()
    i-=1